﻿using System;
using System.Globalization;
using System.Text;

public static class StringExtension
{
    public static string EachWordToTitleCase(this string str)
    {
        string[] words = str.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
        StringBuilder builder = new StringBuilder();
        TextInfo info = new CultureInfo("en-US", false).TextInfo;
        foreach (var word in words)
        {
            string titledWord = info.ToTitleCase(word);
            builder.Append(titledWord);
            builder.Append(' ');
        }
        return builder.ToString().TrimEnd();
    }
}

